File Coverage

blib/lib/PDL/Math.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


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