File Coverage

blib/lib/PDL/Math.pm
Criterion Covered Total %
statement 12 13 92.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 17 94.1


line stmt bran cond sub pod time code
1              
2             #
3             # GENERATED WITH PDL::PP! Don't modify!
4             #
5             package PDL::Math;
6              
7             @EXPORT_OK = qw( PDL::PP acos PDL::PP asin PDL::PP atan PDL::PP cosh PDL::PP sinh PDL::PP tan PDL::PP tanh PDL::PP ceil PDL::PP floor PDL::PP rint PDL::PP pow PDL::PP acosh PDL::PP asinh PDL::PP atanh PDL::PP erf PDL::PP erfc PDL::PP bessj0 PDL::PP bessj1 PDL::PP bessy0 PDL::PP bessy1 PDL::PP bessjn PDL::PP bessyn PDL::PP lgamma PDL::PP badmask PDL::PP isfinite PDL::PP erfi PDL::PP ndtri PDL::PP polyroots );
8             %EXPORT_TAGS = (Func=>[@EXPORT_OK]);
9              
10 122     122   959 use PDL::Core;
  122         281  
  122         995  
11 122     122   977 use PDL::Exporter;
  122         292  
  122         711  
12 122     122   655 use DynaLoader;
  122         275  
  122         8059  
13              
14              
15              
16            
17             @ISA = ( 'PDL::Exporter','DynaLoader' );
18             push @PDL::Core::PP, __PACKAGE__;
19             bootstrap PDL::Math ;
20              
21              
22              
23              
24             =head1 NAME
25              
26             PDL::Math - extended mathematical operations and special functions
27              
28             =head1 SYNOPSIS
29              
30             use PDL::Math;
31              
32             use PDL::Graphics::TriD;
33             imag3d [SURF2D,bessj0(rvals(zeroes(50,50))/2)];
34              
35             =head1 DESCRIPTION
36              
37             This module extends PDL with more advanced mathematical functions than
38             provided by standard Perl.
39              
40             All the functions have one input pdl, and one output, unless otherwise
41             stated.
42              
43             Many of the functions are linked from the system maths library or the
44             Cephes maths library (determined when PDL is compiled); a few are implemented
45             entirely in PDL.
46              
47             =cut
48              
49             ### Kludge for backwards compatibility with older scripts
50             ### This should be deleted at some point later than 21-Nov-2003.
51 122     122   71761 BEGIN {use PDL::MatrixOps;}
  122         410  
  122         1209  
  0            
52              
53              
54              
55              
56              
57              
58              
59             =head1 FUNCTIONS
60              
61              
62              
63             =cut
64              
65              
66              
67              
68              
69              
70             =head2 acos
71              
72             =for sig
73              
74             Signature: (a(); [o]b())
75              
76             The usual trigonometric function.
77             Note that when input is a perl scalar and the real-value based function
78             would return NaN, it now returns a cdouble.
79             Works inplace.
80              
81             =for bad
82              
83             acos processes bad values.
84             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
85              
86              
87             =cut
88              
89              
90              
91              
92              
93              
94             *acos = \&PDL::acos;
95              
96              
97              
98              
99              
100             =head2 asin
101              
102             =for sig
103              
104             Signature: (a(); [o]b())
105              
106             The usual trigonometric function.
107             Note that when input is a perl scalar and the real-value based function
108             would return NaN, it now returns a cdouble.
109             Works inplace.
110              
111             =for bad
112              
113             asin processes bad values.
114             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
115              
116              
117             =cut
118              
119              
120              
121              
122              
123              
124             *asin = \&PDL::asin;
125              
126              
127              
128              
129              
130             =head2 atan
131              
132             =for sig
133              
134             Signature: (a(); [o]b())
135              
136             The usual trigonometric function.
137             Note that when input is a perl scalar and the real-value based function
138             would return NaN, it now returns a cdouble.
139             Works inplace.
140              
141             =for bad
142              
143             atan processes bad values.
144             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
145              
146              
147             =cut
148              
149              
150              
151              
152              
153              
154             *atan = \&PDL::atan;
155              
156              
157              
158              
159              
160             =head2 cosh
161              
162             =for sig
163              
164             Signature: (a(); [o]b())
165              
166             The standard hyperbolic function.
167             Note that when input is a perl scalar and the real-value based function
168             would return NaN, it now returns a cdouble.
169             Works inplace.
170              
171             =for bad
172              
173             cosh processes bad values.
174             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
175              
176              
177             =cut
178              
179              
180              
181              
182              
183              
184             *cosh = \&PDL::cosh;
185              
186              
187              
188              
189              
190             =head2 sinh
191              
192             =for sig
193              
194             Signature: (a(); [o]b())
195              
196             The standard hyperbolic function.
197             Note that when input is a perl scalar and the real-value based function
198             would return NaN, it now returns a cdouble.
199             Works inplace.
200              
201             =for bad
202              
203             sinh processes bad values.
204             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
205              
206              
207             =cut
208              
209              
210              
211              
212              
213              
214             *sinh = \&PDL::sinh;
215              
216              
217              
218              
219              
220             =head2 tan
221              
222             =for sig
223              
224             Signature: (a(); [o]b())
225              
226             The usual trigonometric function.
227             Note that when input is a perl scalar and the real-value based function
228             would return NaN, it now returns a cdouble.
229             Works inplace.
230              
231             =for bad
232              
233             tan processes bad values.
234             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
235              
236              
237             =cut
238              
239              
240              
241              
242              
243              
244             *tan = \&PDL::tan;
245              
246              
247              
248              
249              
250             =head2 tanh
251              
252             =for sig
253              
254             Signature: (a(); [o]b())
255              
256             The standard hyperbolic function.
257             Note that when input is a perl scalar and the real-value based function
258             would return NaN, it now returns a cdouble.
259             Works inplace.
260              
261             =for bad
262              
263             tanh processes bad values.
264             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
265              
266              
267             =cut
268              
269              
270              
271              
272              
273              
274             *tanh = \&PDL::tanh;
275              
276              
277              
278              
279              
280             =head2 ceil
281              
282             =for sig
283              
284             Signature: (a(); [o]b())
285              
286             =for ref
287              
288             Round to integer values in floating-point format. Works inplace.
289              
290             =for bad
291              
292             ceil processes bad values.
293             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
294              
295              
296             =cut
297              
298              
299              
300              
301              
302              
303             *ceil = \&PDL::ceil;
304              
305              
306              
307              
308              
309             =head2 floor
310              
311             =for sig
312              
313             Signature: (a(); [o]b())
314              
315             =for ref
316              
317             Round to integer values in floating-point format. Works inplace.
318              
319             =for bad
320              
321             floor processes bad values.
322             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
323              
324              
325             =cut
326              
327              
328              
329              
330              
331              
332             *floor = \&PDL::floor;
333              
334              
335              
336              
337              
338             =head2 rint
339              
340             =for sig
341              
342             Signature: (a(); [o]b())
343              
344             =for ref
345              
346             Round to integer values in floating-point format.
347              
348             =for method
349              
350             rint uses the 'round half to even' rounding method (also known as
351             banker's rounding). Half-integers are rounded to the nearest even
352             number. This avoids a slight statistical bias inherent in always
353             rounding half-integers up or away from zero.
354              
355             If you are looking to round half-integers up (regardless of sign), try
356             C. If you want to round half-integers away from zero,
357             try C<< ceil(abs($x)+0.5)*($x<=>0) >>. Works inplace.
358              
359             =for bad
360              
361             rint processes bad values.
362             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
363              
364              
365             =cut
366              
367              
368              
369              
370              
371              
372             *rint = \&PDL::rint;
373              
374              
375              
376              
377              
378             =head2 pow
379              
380             =for sig
381              
382             Signature: (a(); b(); [o]c())
383              
384             =for ref
385              
386             Synonym for `**'. Works inplace.
387              
388             =for bad
389              
390             pow processes bad values.
391             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
392              
393              
394             =cut
395              
396              
397              
398              
399              
400              
401             *pow = \&PDL::pow;
402              
403              
404              
405              
406              
407             =head2 acosh
408              
409             =for sig
410              
411             Signature: (a(); [o]b())
412              
413             The standard hyperbolic function.
414             Note that when input is a perl scalar and the real-value based function
415             would return NaN, it now returns a cdouble.
416             Works inplace.
417              
418             =for bad
419              
420             acosh processes bad values.
421             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
422              
423              
424             =cut
425              
426              
427              
428              
429              
430              
431             *acosh = \&PDL::acosh;
432              
433              
434              
435              
436              
437             =head2 asinh
438              
439             =for sig
440              
441             Signature: (a(); [o]b())
442              
443             The standard hyperbolic function.
444             Note that when input is a perl scalar and the real-value based function
445             would return NaN, it now returns a cdouble.
446             Works inplace.
447              
448             =for bad
449              
450             asinh processes bad values.
451             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
452              
453              
454             =cut
455              
456              
457              
458              
459              
460              
461             *asinh = \&PDL::asinh;
462              
463              
464              
465              
466              
467             =head2 atanh
468              
469             =for sig
470              
471             Signature: (a(); [o]b())
472              
473             The standard hyperbolic function.
474             Note that when input is a perl scalar and the real-value based function
475             would return NaN, it now returns a cdouble.
476             Works inplace.
477              
478             =for bad
479              
480             atanh processes bad values.
481             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
482              
483              
484             =cut
485              
486              
487              
488              
489              
490              
491             *atanh = \&PDL::atanh;
492              
493              
494              
495              
496              
497             =head2 erf
498              
499             =for sig
500              
501             Signature: (a(); [o]b())
502              
503             =for ref
504              
505             The error function. Works inplace.
506              
507             =for bad
508              
509             erf processes bad values.
510             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
511              
512              
513             =cut
514              
515              
516              
517              
518              
519              
520             *erf = \&PDL::erf;
521              
522              
523              
524              
525              
526             =head2 erfc
527              
528             =for sig
529              
530             Signature: (a(); [o]b())
531              
532             =for ref
533              
534             The complement of the error function. Works inplace.
535              
536             =for bad
537              
538             erfc processes bad values.
539             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
540              
541              
542             =cut
543              
544              
545              
546              
547              
548              
549             *erfc = \&PDL::erfc;
550              
551              
552              
553              
554              
555             =head2 bessj0
556              
557             =for sig
558              
559             Signature: (a(); [o]b())
560              
561             =for ref
562              
563             The regular Bessel function of the first kind, J_n Works inplace.
564              
565             =for bad
566              
567             bessj0 processes bad values.
568             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
569              
570              
571             =cut
572              
573              
574              
575              
576              
577              
578             *bessj0 = \&PDL::bessj0;
579              
580              
581              
582              
583              
584             =head2 bessj1
585              
586             =for sig
587              
588             Signature: (a(); [o]b())
589              
590             =for ref
591              
592             The regular Bessel function of the first kind, J_n Works inplace.
593              
594             =for bad
595              
596             bessj1 processes bad values.
597             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
598              
599              
600             =cut
601              
602              
603              
604              
605              
606              
607             *bessj1 = \&PDL::bessj1;
608              
609              
610              
611              
612              
613             =head2 bessy0
614              
615             =for sig
616              
617             Signature: (a(); [o]b())
618              
619             =for ref
620              
621             The regular Bessel function of the second kind, Y_n. Works inplace.
622              
623             =for bad
624              
625             bessy0 processes bad values.
626             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
627              
628              
629             =cut
630              
631              
632              
633              
634              
635              
636             *bessy0 = \&PDL::bessy0;
637              
638              
639              
640              
641              
642             =head2 bessy1
643              
644             =for sig
645              
646             Signature: (a(); [o]b())
647              
648             =for ref
649              
650             The regular Bessel function of the second kind, Y_n. Works inplace.
651              
652             =for bad
653              
654             bessy1 processes bad values.
655             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
656              
657              
658             =cut
659              
660              
661              
662              
663              
664              
665             *bessy1 = \&PDL::bessy1;
666              
667              
668              
669              
670              
671             =head2 bessjn
672              
673             =for sig
674              
675             Signature: (a(); int n(); [o]b())
676              
677             =for ref
678              
679             The regular Bessel function of the first kind, J_n
680             .
681             This takes a second int argument which gives the order
682             of the function required.
683             Works inplace.
684              
685             =for bad
686              
687             bessjn processes bad values.
688             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
689              
690              
691             =cut
692              
693              
694              
695              
696              
697              
698             *bessjn = \&PDL::bessjn;
699              
700              
701              
702              
703              
704             =head2 bessyn
705              
706             =for sig
707              
708             Signature: (a(); int n(); [o]b())
709              
710             =for ref
711              
712             The regular Bessel function of the first kind, Y_n
713             .
714             This takes a second int argument which gives the order
715             of the function required.
716             Works inplace.
717              
718             =for bad
719              
720             bessyn processes bad values.
721             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
722              
723              
724             =cut
725              
726              
727              
728              
729              
730              
731             *bessyn = \&PDL::bessyn;
732              
733              
734              
735              
736              
737             =head2 lgamma
738              
739             =for sig
740              
741             Signature: (a(); [o]b(); int[o]s())
742              
743             =for ref
744              
745             log gamma function
746              
747             This returns 2 piddles -- the first set gives the log(gamma) values,
748             while the second set, of integer values, gives the sign of the gamma
749             function. This is useful for determining factorials, amongst other
750             things.
751              
752              
753              
754             =for bad
755              
756             lgamma processes bad values.
757             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
758              
759              
760             =cut
761              
762              
763              
764              
765              
766              
767             *lgamma = \&PDL::lgamma;
768              
769              
770              
771              
772              
773             =head2 badmask
774              
775             =for sig
776              
777             Signature: (a(); b(); [o]c())
778              
779             =for ref
780              
781             Clears all C and C in C<$a> to the corresponding value in C<$b>.
782              
783             badmask can be run with C<$x> inplace:
784              
785             badmask($x->inplace,0);
786             $x->inplace->badmask(0);
787              
788              
789              
790             =for bad
791              
792             If bad values are present, these are also cleared.
793              
794             =cut
795              
796              
797              
798              
799              
800              
801             *badmask = \&PDL::badmask;
802              
803              
804              
805              
806              
807             =head2 isfinite
808              
809             =for sig
810              
811             Signature: (a(); int [o]mask())
812              
813             =for ref
814              
815             Sets C<$mask> true if C<$a> is not a C or C (either positive or negative). Works inplace.
816              
817             =for bad
818              
819             Bad values are treated as C or C.
820              
821             =cut
822              
823              
824              
825              
826              
827              
828             *isfinite = \&PDL::isfinite;
829              
830              
831              
832              
833              
834             =head2 erfi
835              
836             =for sig
837              
838             Signature: (a(); [o]b())
839              
840             =for ref
841              
842             The inverse of the error function. Works inplace.
843              
844             =for bad
845              
846             erfi processes bad values.
847             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
848              
849              
850             =cut
851              
852              
853              
854              
855              
856              
857             *erfi = \&PDL::erfi;
858              
859              
860              
861              
862              
863             =head2 ndtri
864              
865             =for sig
866              
867             Signature: (a(); [o]b())
868              
869             =for ref
870              
871             The value for which the area under the
872             Gaussian probability density function (integrated from
873             minus infinity) is equal to the argument (cf L). Works inplace.
874              
875             =for bad
876              
877             ndtri processes bad values.
878             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
879              
880              
881             =cut
882              
883              
884              
885              
886              
887              
888             *ndtri = \&PDL::ndtri;
889              
890              
891              
892              
893              
894             =head2 polyroots
895              
896             =for sig
897              
898             Signature: (cr(n); ci(n); [o]rr(m); [o]ri(m))
899              
900              
901              
902             =for ref
903              
904             Complex roots of a complex polynomial, given coefficients in order
905             of decreasing powers.
906              
907             =for usage
908              
909             ($rr, $ri) = polyroots($cr, $ci);
910              
911              
912              
913             =for bad
914              
915             polyroots does not process bad values.
916             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
917              
918              
919             =cut
920              
921              
922              
923              
924              
925              
926             *polyroots = \&PDL::polyroots;
927              
928              
929              
930             ;
931              
932              
933             =head1 BUGS
934              
935             Hasn't been tested on all platforms to ensure Cephes
936             versions are picked up automatically and used correctly.
937              
938             =head1 AUTHOR
939              
940             Copyright (C) R.J.R. Williams 1997 (rjrw@ast.leeds.ac.uk), Karl Glazebrook
941             (kgb@aaoepp.aao.gov.au) and Tuomas J. Lukka (Tuomas.Lukka@helsinki.fi).
942             Portions (C) Craig DeForest 2002 (deforest@boulder.swri.edu).
943              
944             All rights reserved. There is no warranty. You are allowed
945             to redistribute this software / documentation under certain
946             conditions. For details, see the file COPYING in the PDL
947             distribution. If this file is separated from the PDL distribution,
948             the PDL copyright notice should be included in the file.
949              
950             =cut
951              
952              
953              
954              
955              
956             # Exit with OK status
957              
958             1;
959              
960