lib/PDL/Math.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 17 / 17 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/PDL/Core/pdlbroadcast.h ↑ Summary lib/PDL/Math/polevl.c »
1 #
2 # GENERATED WITH PDL::PP from lib/PDL/Math.pd! Don't modify!
3 #
4 package PDL::Math;
5  
6 71 our @EXPORT_OK = qw(acos asin atan cosh sinh tan tanh ceil floor rint pow acosh asinh atanh erf erfc bessj0 bessj1 bessy0 bessy1 bessjn bessyn lgamma isfinite erfi ndtri polyroots polyfromroots polyval csqrt clog cacos casin casinh cacosh catanh csqrt_up );
7 71 our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
8  
9 71 ▶use PDL::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 71 ▶use PDL::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 71 ▶use DynaLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14
15 71 our @ISA = ( 'PDL::Exporter','DynaLoader' );
16 71 push @PDL::Core::PP, __PACKAGE__;
17 71 bootstrap PDL::Math ;
18  
19  
20  
21  
22  
23  
24  
25  
26 #line 45 "lib/PDL/Math.pd"
27  
28 use strict;
29 use warnings;
30  
31 =head1 NAME
32  
33 PDL::Math - extended mathematical operations and special functions
34  
35 =head1 SYNOPSIS
36  
37 use PDL::Math;
38  
39 use PDL::Graphics::TriD;
40 imag3d [SURF2D,bessj0(rvals(zeroes(50,50))/2)];
41  
42 =head1 DESCRIPTION
43  
44 This module extends PDL with more advanced mathematical functions than
45 provided by standard Perl.
46  
47 All the functions have one input pdl, and one output, unless otherwise
48 stated.
49  
50 Many of the functions are linked from the system maths library or the
51 Cephes maths library (determined when PDL is compiled); a few are implemented
52 entirely in PDL.
53  
54 =cut
55  
56 ### Kludge for backwards compatibility with older scripts
57 ### This should be deleted at some point later than 21-Nov-2003.
58 BEGIN {use PDL::MatrixOps;}
59 #line 60 "lib/PDL/Math.pm"
60  
61  
62 =head1 FUNCTIONS
63  
64 =cut
65  
66  
67  
68  
69  
70  
71 =head2 acos
72  
73 =for sig
74  
75 Signature: (a(); [o]b())
76 Types: (cfloat cdouble cldouble float double ldouble)
77  
78 =for usage
79  
80 $b = acos($a);
81 acos($a, $b); # all arguments given
82 $b = $a->acos; # method call
83 $a->acos($b);
84 $a->inplace->acos; # can be used inplace
85 acos($a->inplace);
86  
87 The usual trigonometric function.
88  
89 =pod
90  
91 Can operate inplace with C<a> as output C<b>.
92 Broadcasts over its inputs.
93  
94 =for bad
95  
96 C<acos> processes bad values.
97 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
98  
99 =cut
100  
101  
102  
103  
104 *acos = \&PDL::acos;
105  
106  
107  
108  
109  
110  
111 =head2 asin
112  
113 =for sig
114  
115 Signature: (a(); [o]b())
116 Types: (cfloat cdouble cldouble float double ldouble)
117  
118 =for usage
119  
120 $b = asin($a);
121 asin($a, $b); # all arguments given
122 $b = $a->asin; # method call
123 $a->asin($b);
124 $a->inplace->asin; # can be used inplace
125 asin($a->inplace);
126  
127 The usual trigonometric function.
128  
129 =pod
130  
131 Can operate inplace with C<a> as output C<b>.
132 Broadcasts over its inputs.
133  
134 =for bad
135  
136 C<asin> processes bad values.
137 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
138  
139 =cut
140  
141  
142  
143  
144 *asin = \&PDL::asin;
145  
146  
147  
148  
149  
150  
151 =head2 atan
152  
153 =for sig
154  
155 Signature: (a(); [o]b())
156 Types: (cfloat cdouble cldouble float double ldouble)
157  
158 =for usage
159  
160 $b = atan($a);
161 atan($a, $b); # all arguments given
162 $b = $a->atan; # method call
163 $a->atan($b);
164 $a->inplace->atan; # can be used inplace
165 atan($a->inplace);
166  
167 The usual trigonometric function.
168  
169 =pod
170  
171 Can operate inplace with C<a> as output C<b>.
172 Broadcasts over its inputs.
173  
174 =for bad
175  
176 C<atan> processes bad values.
177 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
178  
179 =cut
180  
181  
182  
183  
184 *atan = \&PDL::atan;
185  
186  
187  
188  
189  
190  
191 =head2 cosh
192  
193 =for sig
194  
195 Signature: (a(); [o]b())
196 Types: (cfloat cdouble cldouble float double ldouble)
197  
198 =for usage
199  
200 $b = cosh($a);
201 cosh($a, $b); # all arguments given
202 $b = $a->cosh; # method call
203 $a->cosh($b);
204 $a->inplace->cosh; # can be used inplace
205 cosh($a->inplace);
206  
207 The standard hyperbolic function.
208  
209 =pod
210  
211 Can operate inplace with C<a> as output C<b>.
212 Broadcasts over its inputs.
213  
214 =for bad
215  
216 C<cosh> processes bad values.
217 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
218  
219 =cut
220  
221  
222  
223  
224 *cosh = \&PDL::cosh;
225  
226  
227  
228  
229  
230  
231 =head2 sinh
232  
233 =for sig
234  
235 Signature: (a(); [o]b())
236 Types: (cfloat cdouble cldouble float double ldouble)
237  
238 =for usage
239  
240 $b = sinh($a);
241 sinh($a, $b); # all arguments given
242 $b = $a->sinh; # method call
243 $a->sinh($b);
244 $a->inplace->sinh; # can be used inplace
245 sinh($a->inplace);
246  
247 The standard hyperbolic function.
248  
249 =pod
250  
251 Can operate inplace with C<a> as output C<b>.
252 Broadcasts over its inputs.
253  
254 =for bad
255  
256 C<sinh> processes bad values.
257 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
258  
259 =cut
260  
261  
262  
263  
264 *sinh = \&PDL::sinh;
265  
266  
267  
268  
269  
270  
271 =head2 tan
272  
273 =for sig
274  
275 Signature: (a(); [o]b())
276 Types: (cfloat cdouble cldouble float double ldouble)
277  
278 =for usage
279  
280 $b = tan($a);
281 tan($a, $b); # all arguments given
282 $b = $a->tan; # method call
283 $a->tan($b);
284 $a->inplace->tan; # can be used inplace
285 tan($a->inplace);
286  
287 The usual trigonometric function.
288  
289 =pod
290  
291 Can operate inplace with C<a> as output C<b>.
292 Broadcasts over its inputs.
293  
294 =for bad
295  
296 C<tan> processes bad values.
297 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
298  
299 =cut
300  
301  
302  
303  
304 *tan = \&PDL::tan;
305  
306  
307  
308  
309  
310  
311 =head2 tanh
312  
313 =for sig
314  
315 Signature: (a(); [o]b())
316 Types: (cfloat cdouble cldouble float double ldouble)
317  
318 =for usage
319  
320 $b = tanh($a);
321 tanh($a, $b); # all arguments given
322 $b = $a->tanh; # method call
323 $a->tanh($b);
324 $a->inplace->tanh; # can be used inplace
325 tanh($a->inplace);
326  
327 The standard hyperbolic function.
328  
329 =pod
330  
331 Can operate inplace with C<a> as output C<b>.
332 Broadcasts over its inputs.
333  
334 =for bad
335  
336 C<tanh> processes bad values.
337 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
338  
339 =cut
340  
341  
342  
343  
344 *tanh = \&PDL::tanh;
345  
346  
347  
348  
349  
350  
351 =head2 ceil
352  
353 =for sig
354  
355 Signature: (a(); [o]b())
356 Types: (sbyte byte short ushort long ulong indx ulonglong longlong
357 float double ldouble)
358  
359 =for usage
360  
361 $b = ceil($a);
362 ceil($a, $b); # all arguments given
363 $b = $a->ceil; # method call
364 $a->ceil($b);
365 $a->inplace->ceil; # can be used inplace
366 ceil($a->inplace);
367  
368 =for ref
369  
370 Round to integer values in floating-point format.
371  
372 =pod
373  
374 Can operate inplace with C<a> as output C<b>.
375 Broadcasts over its inputs.
376  
377 =for bad
378  
379 C<ceil> processes bad values.
380 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
381  
382 =cut
383  
384  
385  
386  
387 *ceil = \&PDL::ceil;
388  
389  
390  
391  
392  
393  
394 =head2 floor
395  
396 =for sig
397  
398 Signature: (a(); [o]b())
399 Types: (sbyte byte short ushort long ulong indx ulonglong longlong
400 float double ldouble)
401  
402 =for usage
403  
404 $b = floor($a);
405 floor($a, $b); # all arguments given
406 $b = $a->floor; # method call
407 $a->floor($b);
408 $a->inplace->floor; # can be used inplace
409 floor($a->inplace);
410  
411 =for ref
412  
413 Round to integer values in floating-point format.
414  
415 =pod
416  
417 Can operate inplace with C<a> as output C<b>.
418 Broadcasts over its inputs.
419  
420 =for bad
421  
422 C<floor> processes bad values.
423 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
424  
425 =cut
426  
427  
428  
429  
430 *floor = \&PDL::floor;
431  
432  
433  
434  
435  
436  
437 =head2 rint
438  
439 =for sig
440  
441 Signature: (a(); [o]b())
442 Types: (sbyte byte short ushort long ulong indx ulonglong longlong
443 float double ldouble)
444  
445 =for usage
446  
447 $b = rint($a);
448 rint($a, $b); # all arguments given
449 $b = $a->rint; # method call
450 $a->rint($b);
451 $a->inplace->rint; # can be used inplace
452 rint($a->inplace);
453  
454 =for ref
455  
456 Round to integer values in floating-point format.
457  
458 This is the C99 function; previous to 2.096, the doc referred to a
459 bespoke function that did banker's rounding, but this was not used
460 as a system version will have been detected and used.
461  
462 If you are looking to round half-integers up (regardless of sign), try
463 C<floor($x+0.5)>. If you want to round half-integers away from zero,
464 try C<< ceil(abs($x)+0.5)*($x<=>0) >>.
465  
466 =pod
467  
468 Can operate inplace with C<a> as output C<b>.
469 Broadcasts over its inputs.
470  
471 =for bad
472  
473 C<rint> processes bad values.
474 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
475  
476 =cut
477  
478  
479  
480  
481 *rint = \&PDL::rint;
482  
483  
484  
485  
486  
487  
488 =head2 pow
489  
490 =for sig
491  
492 Signature: (a(); b(); [o]c())
493 Types: (cfloat cdouble cldouble sbyte byte short ushort long
494 ulong indx ulonglong longlong float double ldouble)
495  
496 =for usage
497  
498 $c = pow($a, $b);
499 pow($a, $b, $c); # all arguments given
500 $c = $a->pow($b); # method call
501 $a->pow($b, $c);
502 $a->inplace->pow($b); # can be used inplace
503 pow($a->inplace, $b);
504  
505 =for ref
506  
507 Synonym for `**'.
508  
509 =pod
510  
511 Can operate inplace with C<a> as output C<c>.
512 Broadcasts over its inputs.
513  
514 =for bad
515  
516 C<pow> processes bad values.
517 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
518  
519 =cut
520  
521  
522  
523  
524 *pow = \&PDL::pow;
525  
526  
527  
528  
529  
530  
531 =head2 acosh
532  
533 =for sig
534  
535 Signature: (a(); [o]b())
536 Types: (float double ldouble)
537  
538 =for usage
539  
540 $b = acosh($a);
541 acosh($a, $b); # all arguments given
542 $b = $a->acosh; # method call
543 $a->acosh($b);
544 $a->inplace->acosh; # can be used inplace
545 acosh($a->inplace);
546  
547 The standard hyperbolic function.
548  
549 =pod
550  
551 Can operate inplace with C<a> as output C<b>.
552 Broadcasts over its inputs.
553  
554 =for bad
555  
556 C<acosh> processes bad values.
557 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
558  
559 =cut
560  
561  
562  
563  
564 *acosh = \&PDL::acosh;
565  
566  
567  
568  
569  
570  
571 =head2 asinh
572  
573 =for sig
574  
575 Signature: (a(); [o]b())
576 Types: (float double ldouble)
577  
578 =for usage
579  
580 $b = asinh($a);
581 asinh($a, $b); # all arguments given
582 $b = $a->asinh; # method call
583 $a->asinh($b);
584 $a->inplace->asinh; # can be used inplace
585 asinh($a->inplace);
586  
587 The standard hyperbolic function.
588  
589 =pod
590  
591 Can operate inplace with C<a> as output C<b>.
592 Broadcasts over its inputs.
593  
594 =for bad
595  
596 C<asinh> processes bad values.
597 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
598  
599 =cut
600  
601  
602  
603  
604 *asinh = \&PDL::asinh;
605  
606  
607  
608  
609  
610  
611 =head2 atanh
612  
613 =for sig
614  
615 Signature: (a(); [o]b())
616 Types: (float double ldouble)
617  
618 =for usage
619  
620 $b = atanh($a);
621 atanh($a, $b); # all arguments given
622 $b = $a->atanh; # method call
623 $a->atanh($b);
624 $a->inplace->atanh; # can be used inplace
625 atanh($a->inplace);
626  
627 The standard hyperbolic function.
628  
629 =pod
630  
631 Can operate inplace with C<a> as output C<b>.
632 Broadcasts over its inputs.
633  
634 =for bad
635  
636 C<atanh> processes bad values.
637 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
638  
639 =cut
640  
641  
642  
643  
644 *atanh = \&PDL::atanh;
645  
646  
647  
648  
649  
650  
651 =head2 erf
652  
653 =for sig
654  
655 Signature: (a(); [o]b())
656 Types: (float double ldouble)
657  
658 =for usage
659  
660 $b = erf($a);
661 erf($a, $b); # all arguments given
662 $b = $a->erf; # method call
663 $a->erf($b);
664 $a->inplace->erf; # can be used inplace
665 erf($a->inplace);
666  
667 =for ref
668  
669 The error function.
670  
671 =pod
672  
673 Can operate inplace with C<a> as output C<b>.
674 Broadcasts over its inputs.
675  
676 =for bad
677  
678 C<erf> processes bad values.
679 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
680  
681 =cut
682  
683  
684  
685  
686 *erf = \&PDL::erf;
687  
688  
689  
690  
691  
692  
693 =head2 erfc
694  
695 =for sig
696  
697 Signature: (a(); [o]b())
698 Types: (float double ldouble)
699  
700 =for usage
701  
702 $b = erfc($a);
703 erfc($a, $b); # all arguments given
704 $b = $a->erfc; # method call
705 $a->erfc($b);
706 $a->inplace->erfc; # can be used inplace
707 erfc($a->inplace);
708  
709 =for ref
710  
711 The complement of the error function.
712  
713 =pod
714  
715 Can operate inplace with C<a> as output C<b>.
716 Broadcasts over its inputs.
717  
718 =for bad
719  
720 C<erfc> processes bad values.
721 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
722  
723 =cut
724  
725  
726  
727  
728 *erfc = \&PDL::erfc;
729  
730  
731  
732  
733  
734  
735 =head2 bessj0
736  
737 =for sig
738  
739 Signature: (a(); [o]b())
740 Types: (float double ldouble)
741  
742 =for usage
743  
744 $b = bessj0($a);
745 bessj0($a, $b); # all arguments given
746 $b = $a->bessj0; # method call
747 $a->bessj0($b);
748 $a->inplace->bessj0; # can be used inplace
749 bessj0($a->inplace);
750  
751 =for ref
752  
753 The regular Bessel function of the first kind, J_n
754  
755 =pod
756  
757 Can operate inplace with C<a> as output C<b>.
758 Broadcasts over its inputs.
759  
760 =for bad
761  
762 C<bessj0> processes bad values.
763 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
764  
765 =cut
766  
767  
768  
769  
770 *bessj0 = \&PDL::bessj0;
771  
772  
773  
774  
775  
776  
777 =head2 bessj1
778  
779 =for sig
780  
781 Signature: (a(); [o]b())
782 Types: (float double ldouble)
783  
784 =for usage
785  
786 $b = bessj1($a);
787 bessj1($a, $b); # all arguments given
788 $b = $a->bessj1; # method call
789 $a->bessj1($b);
790 $a->inplace->bessj1; # can be used inplace
791 bessj1($a->inplace);
792  
793 =for ref
794  
795 The regular Bessel function of the first kind, J_n
796  
797 =pod
798  
799 Can operate inplace with C<a> as output C<b>.
800 Broadcasts over its inputs.
801  
802 =for bad
803  
804 C<bessj1> processes bad values.
805 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
806  
807 =cut
808  
809  
810  
811  
812 *bessj1 = \&PDL::bessj1;
813  
814  
815  
816  
817  
818  
819 =head2 bessy0
820  
821 =for sig
822  
823 Signature: (a(); [o]b())
824 Types: (float double ldouble)
825  
826 =for usage
827  
828 $b = bessy0($a);
829 bessy0($a, $b); # all arguments given
830 $b = $a->bessy0; # method call
831 $a->bessy0($b);
832 $a->inplace->bessy0; # can be used inplace
833 bessy0($a->inplace);
834  
835 =for ref
836  
837 The regular Bessel function of the second kind, Y_n.
838  
839 =pod
840  
841 Can operate inplace with C<a> as output C<b>.
842 Broadcasts over its inputs.
843  
844 =for bad
845  
846 C<bessy0> processes bad values.
847 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
848  
849 =cut
850  
851  
852  
853  
854 *bessy0 = \&PDL::bessy0;
855  
856  
857  
858  
859  
860  
861 =head2 bessy1
862  
863 =for sig
864  
865 Signature: (a(); [o]b())
866 Types: (float double ldouble)
867  
868 =for usage
869  
870 $b = bessy1($a);
871 bessy1($a, $b); # all arguments given
872 $b = $a->bessy1; # method call
873 $a->bessy1($b);
874 $a->inplace->bessy1; # can be used inplace
875 bessy1($a->inplace);
876  
877 =for ref
878  
879 The regular Bessel function of the second kind, Y_n.
880  
881 =pod
882  
883 Can operate inplace with C<a> as output C<b>.
884 Broadcasts over its inputs.
885  
886 =for bad
887  
888 C<bessy1> processes bad values.
889 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
890  
891 =cut
892  
893  
894  
895  
896 *bessy1 = \&PDL::bessy1;
897  
898  
899  
900  
901  
902  
903 =head2 bessjn
904  
905 =for sig
906  
907 Signature: (a(); int n(); [o]b())
908 Types: (float double ldouble)
909  
910 =for usage
911  
912 $b = bessjn($a, $n);
913 bessjn($a, $n, $b); # all arguments given
914 $b = $a->bessjn($n); # method call
915 $a->bessjn($n, $b);
916 $a->inplace->bessjn($n); # can be used inplace
917 bessjn($a->inplace, $n);
918  
919 =for ref
920  
921 The regular Bessel function of the first kind, J_n
922 .
923 This takes a second int argument which gives the order
924 of the function required.
925  
926 =pod
927  
928 Can operate inplace with C<a> as output C<b>.
929 Broadcasts over its inputs.
930  
931 =for bad
932  
933 C<bessjn> processes bad values.
934 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
935  
936 =cut
937  
938  
939  
940  
941 *bessjn = \&PDL::bessjn;
942  
943  
944  
945  
946  
947  
948 =head2 bessyn
949  
950 =for sig
951  
952 Signature: (a(); int n(); [o]b())
953 Types: (float double ldouble)
954  
955 =for usage
956  
957 $b = bessyn($a, $n);
958 bessyn($a, $n, $b); # all arguments given
959 $b = $a->bessyn($n); # method call
960 $a->bessyn($n, $b);
961 $a->inplace->bessyn($n); # can be used inplace
962 bessyn($a->inplace, $n);
963  
964 =for ref
965  
966 The regular Bessel function of the first kind, Y_n
967 .
968 This takes a second int argument which gives the order
969 of the function required.
970  
971 =pod
972  
973 Can operate inplace with C<a> as output C<b>.
974 Broadcasts over its inputs.
975  
976 =for bad
977  
978 C<bessyn> processes bad values.
979 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
980  
981 =cut
982  
983  
984  
985  
986 *bessyn = \&PDL::bessyn;
987  
988  
989  
990  
991  
992  
993 =head2 lgamma
994  
995 =for sig
996  
997 Signature: (a(); [o]b(); int[o]s())
998 Types: (sbyte byte short ushort long ulong indx ulonglong longlong
999 float double ldouble)
1000  
1001 =for usage
1002  
1003 ($b, $s) = lgamma($a);
1004 lgamma($a, $b, $s); # all arguments given
1005 ($b, $s) = $a->lgamma; # method call
1006 $a->lgamma($b, $s);
1007  
1008 =for ref
1009  
1010 log gamma function
1011  
1012 This returns 2 ndarrays -- the first set gives the log(gamma) values,
1013 while the second set, of integer values, gives the sign of the gamma
1014 function. This is useful for determining factorials, amongst other
1015 things.
1016  
1017 =pod
1018  
1019 Broadcasts over its inputs.
1020  
1021 =for bad
1022  
1023 C<lgamma> processes bad values.
1024 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1025  
1026 =cut
1027  
1028  
1029  
1030  
1031 *lgamma = \&PDL::lgamma;
1032  
1033  
1034  
1035  
1036  
1037  
1038 =head2 isfinite
1039  
1040 =for sig
1041  
1042 Signature: (a(); int [o]mask())
1043 Types: (sbyte byte short ushort long ulong indx ulonglong longlong
1044 float double ldouble)
1045  
1046 =for usage
1047  
1048 $mask = isfinite($a);
1049 isfinite($a, $mask); # all arguments given
1050 $mask = $a->isfinite; # method call
1051 $a->isfinite($mask);
1052  
1053 =for ref
1054  
1055 Sets C<$mask> true if C<$a> is not a C<NaN> or C<inf> (either positive or negative).
1056  
1057 =pod
1058  
1059 Broadcasts over its inputs.
1060  
1061 =for bad
1062  
1063 Bad values are treated as C<NaN> or C<inf>.
1064  
1065 =cut
1066  
1067  
1068  
1069  
1070 *isfinite = \&PDL::isfinite;
1071  
1072  
1073  
1074  
1075  
1076  
1077 =head2 erfi
1078  
1079 =for sig
1080  
1081 Signature: (a(); [o]b())
1082 Types: (float double ldouble)
1083  
1084 =for usage
1085  
1086 $b = erfi($a);
1087 erfi($a, $b); # all arguments given
1088 $b = $a->erfi; # method call
1089 $a->erfi($b);
1090 $a->inplace->erfi; # can be used inplace
1091 erfi($a->inplace);
1092  
1093 =for ref
1094  
1095 erfi
1096  
1097 =pod
1098  
1099 Can operate inplace with C<a> as output C<b>.
1100 Broadcasts over its inputs.
1101  
1102 =for bad
1103  
1104 C<erfi> processes bad values.
1105 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1106  
1107 =cut
1108  
1109  
1110  
1111  
1112 *erfi = \&PDL::erfi;
1113  
1114  
1115  
1116  
1117  
1118  
1119 =head2 ndtri
1120  
1121 =for sig
1122  
1123 Signature: (a(); [o]b())
1124 Types: (float double ldouble)
1125  
1126 =for usage
1127  
1128 $b = ndtri($a);
1129 ndtri($a, $b); # all arguments given
1130 $b = $a->ndtri; # method call
1131 $a->ndtri($b);
1132 $a->inplace->ndtri; # can be used inplace
1133 ndtri($a->inplace);
1134  
1135 =for ref
1136  
1137 ndtri
1138  
1139 =pod
1140  
1141 Can operate inplace with C<a> as output C<b>.
1142 Broadcasts over its inputs.
1143  
1144 =for bad
1145  
1146 C<ndtri> processes bad values.
1147 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1148  
1149 =cut
1150  
1151  
1152  
1153  
1154 *ndtri = \&PDL::ndtri;
1155  
1156  
1157  
1158  
1159  
1160  
1161 =head2 polyroots
1162  
1163 =for sig
1164  
1165 Signature: (cr(n); ci(n); [o]rr(m=CALC($SIZE(n)-1)); [o]ri(m))
1166 Types: (double)
1167  
1168 =for ref
1169  
1170 Complex roots of a complex polynomial, given coefficients in order
1171 of decreasing powers. Only works for degree >= 1.
1172 Uses the Jenkins-Traub algorithm (see
1173 L<https://en.wikipedia.org/wiki/Jenkins%E2%80%93Traub_algorithm>).
1174 As of 2.086, works with native-complex data.
1175  
1176 =for usage
1177  
1178 $roots = polyroots($coeffs); # native complex
1179 polyroots($coeffs, $roots=null); # native complex
1180 ($rr, $ri) = polyroots($cr, $ci);
1181 polyroots($cr, $ci, $rr, $ri);
1182  
1183 =pod
1184  
1185 Broadcasts over its inputs.
1186  
1187 =for bad
1188  
1189 C<polyroots> does not process bad values.
1190 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1191  
1192 =cut
1193  
1194  
1195  
1196  
1197  
1198 #line 367 "lib/PDL/Math.pd"
1199 sub PDL::polyroots {
1200 my @args = map PDL->topdl($_), @_;
1201 my $natcplx = !$args[0]->type->real;
1202 barf "need array context if give real data and no outputs"
1203 if !$natcplx and @_ < 3 and !(wantarray//1);
1204 splice @args, 0, 1, map $args[0]->$_, qw(re im) if $natcplx;
1205 my @ins = splice @args, 0, 2;
1206 my $explicit_out = my @outs = @args;
1207 if ($natcplx) {
1208 $_ //= PDL->null for $outs[0];
1209 } else {
1210 $_ //= PDL->null for @outs[0,1];
1211 }
1212 my @args_out = $natcplx ? (map PDL->null, 1..2) : @outs; # opposite from polyfromroots
1213 PDL::_polyroots_int(@ins, @args_out);
1214 return @args_out if !$natcplx;
1215 $outs[0] .= PDL::czip(@args_out[0,1]);
1216 }
1217 #line 1218 "lib/PDL/Math.pm"
1218  
1219 *polyroots = \&PDL::polyroots;
1220  
1221  
1222  
1223  
1224  
1225  
1226 =head2 polyfromroots
1227  
1228 =for sig
1229  
1230 Signature: (r(m); [o]c(n=CALC($SIZE(m)+1)))
1231 Types: (cdouble)
1232  
1233 =for ref
1234  
1235 Calculates the complex coefficients of a polynomial from its complex
1236 roots, in order of decreasing powers. Added in 2.086, works with
1237 native-complex data.
1238  
1239 Algorithm is from Octave poly.m, O(n^2), per
1240 L<https://cs.stackexchange.com/questions/116643/what-is-the-most-efficient-algorithm-to-compute-polynomial-coefficients-from-its>;
1241 using an FFT would allow O(n*log(n)^2).
1242  
1243 =for usage
1244  
1245 $coeffs = polyfromroots($roots); # native complex
1246 ($cr, $ci) = polyfromroots($rr, $ri);
1247  
1248 =pod
1249  
1250 Broadcasts over its inputs.
1251  
1252 =for bad
1253  
1254 C<polyfromroots> does not process bad values.
1255 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1256  
1257 =cut
1258  
1259  
1260  
1261  
1262  
1263 #line 416 "lib/PDL/Math.pd"
1264 sub PDL::polyfromroots {
1265 my @args = map PDL->topdl($_), @_;
1266 my $natcplx = !$args[0]->type->real;
1267 barf "need array context" if !$natcplx and !(wantarray//1);
1268 if (!$natcplx) {
1269 splice @args, 0, 2, $args[0]->czip($args[1]); # r
1270 }
1271 my @ins = splice @args, 0, 1;
1272 my $explicit_out = my @outs = @args;
1273 if ($natcplx) {
1274 $_ //= PDL->null for $outs[0];
1275 } else {
1276 $_ //= PDL->null for @outs[0,1];
1277 }
1278 my @args_out = $natcplx ? @outs : PDL->null;
1279 PDL::_polyfromroots_int(@ins, @args_out);
1280 if (!$natcplx) {
1281 $outs[0] .= $args_out[0]->re;
1282 $outs[1] .= $args_out[0]->im;
1283 }
1284 $natcplx ? $outs[0] : @outs;
1285 }
1286 #line 1287 "lib/PDL/Math.pm"
1287  
1288 *polyfromroots = \&PDL::polyfromroots;
1289  
1290  
1291  
1292  
1293  
1294  
1295 =head2 polyval
1296  
1297 =for sig
1298  
1299 Signature: (c(n); x(); [o]y())
1300 Types: (cdouble)
1301  
1302 =for ref
1303  
1304 Complex value of a complex polynomial at given point, given coefficients
1305 in order of decreasing powers. Uses Horner recurrence. Added in 2.086,
1306 works with native-complex data.
1307  
1308 =for usage
1309  
1310 $y = polyval($coeffs, $x); # native complex
1311 ($yr, $yi) = polyval($cr, $ci, $xr, $xi);
1312  
1313 =pod
1314  
1315 Broadcasts over its inputs.
1316  
1317 =for bad
1318  
1319 C<polyval> does not process bad values.
1320 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1321  
1322 =cut
1323  
1324  
1325  
1326  
1327  
1328 #line 465 "lib/PDL/Math.pd"
1329 sub PDL::polyval {
1330 my @args = map PDL->topdl($_), @_;
1331 my $natcplx = !$args[0]->type->real;
1332 barf "need array context" if !$natcplx and !(wantarray//1);
1333 if (!$natcplx) {
1334 splice @args, 0, 2, $args[0]->czip($args[1]); # c
1335 splice @args, 1, 2, $args[1]->czip($args[2]); # x
1336 }
1337 my @ins = splice @args, 0, 2;
1338 my $explicit_out = my @outs = @args;
1339 if ($natcplx) {
1340 $_ //= PDL->null for $outs[0];
1341 } else {
1342 $_ //= PDL->null for @outs[0,1];
1343 }
1344 my @args_out = $natcplx ? @outs : PDL->null;
1345 PDL::_polyval_int(@ins, @args_out);
1346 if (!$natcplx) {
1347 $outs[0] .= $args_out[0]->re;
1348 $outs[1] .= $args_out[0]->im;
1349 }
1350 $natcplx ? $outs[0] : @outs;
1351 }
1352 #line 1353 "lib/PDL/Math.pm"
1353  
1354 *polyval = \&PDL::polyval;
1355  
1356  
1357  
1358  
1359  
1360  
1361 =head2 csqrt
1362  
1363 =for sig
1364  
1365 Signature: (i(); complex [o] o())
1366 Types: (float ldouble cfloat cdouble cldouble double)
1367  
1368 =for usage
1369  
1370 $o = csqrt($i);
1371 csqrt($i, $o); # all arguments given
1372 $o = $i->csqrt; # method call
1373 $i->csqrt($o);
1374  
1375 =for ref
1376  
1377 Takes real or complex data, returns the complex C<sqrt>.
1378  
1379 Added in 2.099.
1380  
1381 =pod
1382  
1383 Broadcasts over its inputs.
1384  
1385 =for bad
1386  
1387 C<csqrt> does not process bad values.
1388 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1389  
1390 =cut
1391  
1392  
1393  
1394  
1395 *csqrt = \&PDL::csqrt;
1396  
1397  
1398  
1399  
1400  
1401  
1402 =head2 clog
1403  
1404 =for sig
1405  
1406 Signature: (i(); complex [o] o())
1407 Types: (float ldouble cfloat cdouble cldouble double)
1408  
1409 =for usage
1410  
1411 $o = clog($i);
1412 clog($i, $o); # all arguments given
1413 $o = $i->clog; # method call
1414 $i->clog($o);
1415  
1416 =for ref
1417  
1418 Takes real or complex data, returns the complex C<log>.
1419  
1420 Added in 2.099.
1421  
1422 =pod
1423  
1424 Broadcasts over its inputs.
1425  
1426 =for bad
1427  
1428 C<clog> does not process bad values.
1429 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1430  
1431 =cut
1432  
1433  
1434  
1435  
1436 *clog = \&PDL::clog;
1437  
1438  
1439  
1440  
1441  
1442  
1443 =head2 cacos
1444  
1445 =for sig
1446  
1447 Signature: (i(); complex [o] o())
1448 Types: (float ldouble cfloat cdouble cldouble double)
1449  
1450 =for usage
1451  
1452 $o = cacos($i);
1453 cacos($i, $o); # all arguments given
1454 $o = $i->cacos; # method call
1455 $i->cacos($o);
1456  
1457 =for ref
1458  
1459 Takes real or complex data, returns the complex C<acos>.
1460  
1461 Added in 2.099.
1462  
1463 =pod
1464  
1465 Broadcasts over its inputs.
1466  
1467 =for bad
1468  
1469 C<cacos> does not process bad values.
1470 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1471  
1472 =cut
1473  
1474  
1475  
1476  
1477 *cacos = \&PDL::cacos;
1478  
1479  
1480  
1481  
1482  
1483  
1484 =head2 casin
1485  
1486 =for sig
1487  
1488 Signature: (i(); complex [o] o())
1489 Types: (float ldouble cfloat cdouble cldouble double)
1490  
1491 =for usage
1492  
1493 $o = casin($i);
1494 casin($i, $o); # all arguments given
1495 $o = $i->casin; # method call
1496 $i->casin($o);
1497  
1498 =for ref
1499  
1500 Takes real or complex data, returns the complex C<asin>.
1501  
1502 Added in 2.099.
1503  
1504 =pod
1505  
1506 Broadcasts over its inputs.
1507  
1508 =for bad
1509  
1510 C<casin> does not process bad values.
1511 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1512  
1513 =cut
1514  
1515  
1516  
1517  
1518 *casin = \&PDL::casin;
1519  
1520  
1521  
1522  
1523  
1524  
1525 =head2 casinh
1526  
1527 =for sig
1528  
1529 Signature: (i(); complex [o] o())
1530 Types: (float ldouble cfloat cdouble cldouble double)
1531  
1532 =for usage
1533  
1534 $o = casinh($i);
1535 casinh($i, $o); # all arguments given
1536 $o = $i->casinh; # method call
1537 $i->casinh($o);
1538  
1539 =for ref
1540  
1541 Takes real or complex data, returns the complex C<asinh>.
1542  
1543 Added in 2.099.
1544  
1545 =pod
1546  
1547 Broadcasts over its inputs.
1548  
1549 =for bad
1550  
1551 C<casinh> does not process bad values.
1552 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1553  
1554 =cut
1555  
1556  
1557  
1558  
1559 *casinh = \&PDL::casinh;
1560  
1561  
1562  
1563  
1564  
1565  
1566 =head2 cacosh
1567  
1568 =for sig
1569  
1570 Signature: (i(); complex [o] o())
1571 Types: (float ldouble cfloat cdouble cldouble double)
1572  
1573 =for usage
1574  
1575 $o = cacosh($i);
1576 cacosh($i, $o); # all arguments given
1577 $o = $i->cacosh; # method call
1578 $i->cacosh($o);
1579  
1580 =for ref
1581  
1582 Takes real or complex data, returns the complex C<acosh>.
1583  
1584 Added in 2.099.
1585  
1586 =pod
1587  
1588 Broadcasts over its inputs.
1589  
1590 =for bad
1591  
1592 C<cacosh> does not process bad values.
1593 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1594  
1595 =cut
1596  
1597  
1598  
1599  
1600 *cacosh = \&PDL::cacosh;
1601  
1602  
1603  
1604  
1605  
1606  
1607 =head2 catanh
1608  
1609 =for sig
1610  
1611 Signature: (i(); complex [o] o())
1612 Types: (float ldouble cfloat cdouble cldouble double)
1613  
1614 =for usage
1615  
1616 $o = catanh($i);
1617 catanh($i, $o); # all arguments given
1618 $o = $i->catanh; # method call
1619 $i->catanh($o);
1620  
1621 =for ref
1622  
1623 Takes real or complex data, returns the complex C<atanh>.
1624  
1625 Added in 2.099.
1626  
1627 =pod
1628  
1629 Broadcasts over its inputs.
1630  
1631 =for bad
1632  
1633 C<catanh> does not process bad values.
1634 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1635  
1636 =cut
1637  
1638  
1639  
1640  
1641 *catanh = \&PDL::catanh;
1642  
1643  
1644  
1645  
1646  
1647  
1648 =head2 csqrt_up
1649  
1650 =for sig
1651  
1652 Signature: (i(); complex [o] o())
1653 Types: (float ldouble cfloat cdouble cldouble double)
1654  
1655 =for usage
1656  
1657 $o = csqrt_up($i);
1658 csqrt_up($i, $o); # all arguments given
1659 $o = $i->csqrt_up; # method call
1660 $i->csqrt_up($o);
1661  
1662 Take the complex square root of a number choosing that whose imaginary
1663 part is not negative, i.e., it is a square root with a branch cut
1664 'infinitesimally' below the positive real axis.
1665  
1666 =pod
1667  
1668 Broadcasts over its inputs.
1669  
1670 =for bad
1671  
1672 C<csqrt_up> does not process bad values.
1673 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1674  
1675 =cut
1676  
1677  
1678  
1679  
1680 *csqrt_up = \&PDL::csqrt_up;
1681  
1682  
1683  
1684  
1685  
1686  
1687  
1688 #line 540 "lib/PDL/Math.pd"
1689  
1690 =head1 AUTHOR
1691  
1692 Copyright (C) R.J.R. Williams 1997 (rjrw@ast.leeds.ac.uk), Karl Glazebrook
1693 (kgb@aaoepp.aao.gov.au) and Tuomas J. Lukka (Tuomas.Lukka@helsinki.fi).
1694 Portions (C) Craig DeForest 2002 (deforest@boulder.swri.edu).
1695  
1696 All rights reserved. There is no warranty. You are allowed
1697 to redistribute this software / documentation under certain
1698 conditions. For details, see the file COPYING in the PDL
1699 distribution. If this file is separated from the PDL distribution,
1700 the PDL copyright notice should be included in the file.
1701  
1702 =cut
1703  
1704 #line 560 "lib/PDL/Math.pd"
1705 our %got_complex = (
1706 acos => 1,
1707 acosh => 1,
1708 asin => 1,
1709 asinh => 1,
1710 atan => 1,
1711 atanh => 1,
1712 cosh => 1,
1713 log => 1,
1714 pow => 1,
1715 sinh => 1,
1716 sqrt => 1,
1717 tan => 1,
1718 tanh => 1,
1719 );
1720 #line 1721 "lib/PDL/Math.pm"
1721  
1722 # Exit with OK status
1723  
1724 1;
« lib/PDL/Core/pdlbroadcast.h ↑ Summary lib/PDL/Math/polevl.c »