File Coverage

blib/lib/PDL.pm
Criterion Covered Total %
statement 53 53 100.0
branch 1 4 25.0
condition n/a
subroutine 18 18 100.0
pod 0 1 0.0
total 72 76 94.7


line stmt bran cond sub pod time code
1             package PDL;
2              
3 72     72   557940 use strict;
  72         171  
  72         2940  
4 72     72   397 use warnings;
  72         160  
  72         21968  
5              
6             # set the version - this is the real location again
7             our $VERSION = '2.103';
8              
9             =head1 NAME
10              
11             PDL - the Perl Data Language
12              
13             =head1 SYNOPSIS
14              
15             use PDL;
16             $x = zeroes 3,3; # 3x3 matrix
17             $y = $x + 0.1 * xvals($x) + 0.01 * yvals($x);
18             print $y;
19             print $y->slice(":,1"); # row 2
20             print $diag = $y->diagonal(0,1), "\n"; # 0 and 1 are the dimensions
21             $diag += 100;
22             print "AFTER, y=$y";
23             [
24             [ 0 0.1 0.2]
25             [0.01 0.11 0.21]
26             [0.02 0.12 0.22]
27             ]
28             [
29             [0.01 0.11 0.21]
30             ]
31             [0 0.11 0.22]
32             AFTER, y=
33             [
34             [ 100 0.1 0.2]
35             [ 0.01 100.11 0.21]
36             [ 0.02 0.12 100.22]
37             ]
38              
39             =head1 DESCRIPTION
40              
41             (For the exported PDL constructor, pdl(), see L)
42              
43             PDL is the Perl Data Language, a perl extension that is designed for
44             scientific and bulk numeric data processing and display. It extends
45             perl's syntax and includes fully vectorized, multidimensional array
46             handling, plus several paths for device-independent graphics output.
47              
48             PDL is fast, comparable and often outperforming IDL and MATLAB in real
49             world applications. PDL allows large N-dimensional data sets such as large
50             images, spectra, etc to be stored efficiently and manipulated quickly.
51              
52             =head1 VECTORIZATION
53              
54             For a description of the vectorization (also called "broadcasting"), see
55             L.
56              
57             =head1 INTERACTIVE SHELL
58              
59             The PDL package includes an interactive shell. You can learn about it,
60             run C, or run the shell C and type
61             C.
62              
63             =head1 LOOKING FOR A FUNCTION?
64              
65             If you want to search for a function name, you should use the PDL
66             shell along with the "help" or "apropos" command (to do a fuzzy search).
67             For example:
68              
69             pdl> apropos xval
70             xlinvals X axis values between endpoints (see xvals).
71             xlogvals X axis values logarithmicly spaced...
72             xvals Fills an ndarray with X index values...
73             yvals Fills an ndarray with Y index values. See the CAVEAT for xvals.
74             zvals Fills an ndarray with Z index values. See the CAVEAT for xvals.
75              
76             To learn more about the PDL shell, see L.
77              
78             =head1 LANGUAGE DOCUMENTATION
79              
80             Most PDL documentation describes the language features. The number of
81             PDL pages is too great to list here. The following pages offer some
82             guidance to help you find the documentation you need.
83              
84             =over 5
85              
86             =item L
87              
88             Frequently asked questions about PDL. This page covers a lot of
89             questions that do not fall neatly into any of the documentation
90             categories.
91              
92             =item L
93              
94             A guide to PDL's tutorial-style documentation. With topics from beginner
95             to advanced, these pages teach you various aspects of PDL step by step.
96              
97             =item L
98              
99             A guide to PDL's module reference. Modules are organized by level
100             (foundation to advanced) and by category (graphics, numerical methods,
101             etc) to help you find the module you need as quickly as possible.
102              
103             =item L
104              
105             This page compiles PDL's tutorial and reference pages into a comprehensive
106             course that takes you from a complete beginner level to expert.
107              
108             =item L
109              
110             List of all available documentation, sorted alphabetically. If you
111             cannot find what you are looking for, try here.
112              
113             =item L
114              
115             A guide for people who want to contribute to PDL. Contributions are
116             very welcome!
117              
118             =back
119              
120             =head1 DATA TYPES
121              
122             PDL comes with support for most native numeric data types available in C.
123             2.027 added support for C99 complex numbers. See
124             L, L and L for details on usage and
125             behaviour.
126              
127             =head1 MODULES
128              
129             PDL includes about a dozen perl modules that form the core of the
130             language, plus additional modules that add further functionality.
131             The perl module "PDL" loads all of the core modules automatically,
132             making their functions available in the current perl namespace.
133             Some notes:
134              
135             =over 5
136              
137             =item Modules loaded by default
138              
139             use PDL; # Is equivalent to the following:
140              
141             use PDL::Core;
142             use PDL::Ops;
143             use PDL::Primitive;
144             use PDL::Ufunc;
145             use PDL::Basic;
146             use PDL::Slices;
147             use PDL::Bad;
148             use PDL::MatrixOps;
149             use PDL::Math;
150             use PDL::IO::Misc;
151             use PDL::IO::FITS;
152             use PDL::IO::Pic;
153             use PDL::IO::Storable;
154              
155             =cut
156              
157             # Main loader of standard PDL package
158              
159             sub import {
160 14     14   10179 my $pkg = (caller())[0];
161 14     12   1217 eval <<"EOD";
  12     12   6815  
  12     12   67  
  12     12   573  
  12     12   5944  
  12     12   61  
  12     12   142  
  12     12   8927  
  12     10   62  
  12     10   113  
  12     10   6043  
  12     10   55  
  12     10   232  
  12         4250  
  12         57  
  12         102  
  12         123  
  12         55  
  12         150  
  12         5394  
  12         51  
  12         126  
  12         94  
  12         39  
  12         110  
  12         92  
  10         23  
  10         142  
  10         7509  
  10         50  
  10         125  
  10         8538  
  10         62  
  10         175  
  10         7568  
  10         60  
  10         154  
  10         6584  
  10         44  
  10         112  
162             package $pkg;
163             # Load the fundamental packages
164             use PDL::Core;
165             use PDL::Ops;
166             use PDL::Primitive;
167             use PDL::Ufunc;
168             use PDL::Basic;
169             use PDL::Slices;
170             use PDL::Bad;
171             use PDL::MatrixOps;
172             use PDL::Math;
173             # for TPJ compatibility
174             use PDL::IO::Misc; # Misc IO (Ascii)
175             use PDL::IO::FITS; # FITS IO (rfits/wfits; used by rpic/wpic too)
176             use PDL::IO::Pic; # rpic/wpic
177             # end TPJ bit
178             use PDL::IO::Storable; # to avoid mysterious Storable segfaults
179             EOD
180 14 50       614 die $@ if $@;
181             }
182              
183             =item L and L
184              
185             These are lighter-weight alternatives to the standard PDL module.
186             Consider using these modules if startup time becomes an issue.
187              
188             Note that L and L are
189             I included in the L and L
190             start-up modules.
191              
192             =item Exports
193              
194             C exports a large number of routines into the calling
195             namespace. If you want to avoid namespace pollution, you must instead
196             C, and include any additional modules explicitly.
197              
198             =item L
199              
200             Note that the L syntax is NOT automatically
201             loaded by C. If you want to use the extended slicing syntax in
202             a standalone script, you must also say C.
203              
204             =back
205              
206             =head1 INTERNATIONALIZATION
207              
208             PDL currently does not have internationalization support for
209             its error messages although Perl itself does support i18n
210             and locales. Some of the tests for names and strings are
211             specific to ASCII and English. Please report any issues
212             regarding internationalization to the perldl mailing lists.
213              
214             Of course, volunteers to implement this or help with the
215             translations would be welcome.
216              
217             =head1 INSTALLATION
218              
219             See L for help.
220              
221             =cut
222              
223             # support: use Inline with => 'PDL';
224             # Returns a hash containing parameters accepted by recent versions of
225             # Inline, to tweak compilation. Not normally called by anyone but
226             # the Inline API.
227             sub Inline {
228 3     3 0 449799 require PDL::Install::Files;
229 3         14 goto &PDL::Install::Files::Inline;
230             }
231              
232             ##################################################
233             # Rudimentary handling for multiple Perl threads #
234             ##################################################
235             our $no_clone_skip_warning = 0;
236             sub CLONE_SKIP {
237 2 0   2   21 warn <<'EOF' if !$no_clone_skip_warning;
238             * If you need to share PDL data across threads, use memory mapped data, or
239             * check out PDL::Parallel::threads, available on CPAN.
240             * You can silence this warning by saying `$PDL::no_clone_skip_warning = 1;'
241             * before you create your first thread.
242             EOF
243 2         17 $no_clone_skip_warning = 1;
244             # always return 1 to tell Perl not to clone PDL data
245 2         5 return 1;
246             }
247              
248             1;