File Coverage

blib/lib/PDL/NDBin/Actions_PP.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 13 13 100.0


line stmt bran cond sub pod time code
1              
2             #
3             # GENERATED WITH PDL::PP! Don't modify!
4             #
5             package PDL::NDBin::Actions_PP;
6              
7             @EXPORT_OK = qw( PDL::PP _flatten_into PDL::PP _flatten_into_grid PDL::PP _setnulltobad PDL::PP _icount_loop PDL::PP _imax_loop PDL::PP _imin_loop PDL::PP _isum_loop PDL::PP _iavg_loop PDL::PP _istddev_loop PDL::PP _istddev_post );
8             %EXPORT_TAGS = (Func=>[@EXPORT_OK]);
9              
10 5     5   302159 use PDL::Core;
  5         16  
  5         32  
11 5     5   1314 use PDL::Exporter;
  5         11  
  5         24  
12 5     5   154 use DynaLoader;
  5         10  
  5         394  
13              
14              
15              
16             $PDL::NDBin::Actions_PP::VERSION = 0.020;
17             @ISA = ( 'PDL::Exporter','DynaLoader' );
18             push @PDL::Core::PP, __PACKAGE__;
19             bootstrap PDL::NDBin::Actions_PP $VERSION;
20              
21              
22       5     BEGIN {
23              
24             # ABSTRACT: XS actions for PDL::NDBin
25              
26             =head1 NAME
27              
28             PDL::NDBin::Actions_PP - XS actions for PDL::NDBin
29              
30             =head1 DESCRIPTION
31              
32             This module contains the implementation of the core loop of the action classes
33             in the PDL::NDBin::Action namespace. The subroutines are not intended to be
34             called by the user.
35              
36             =cut
37              
38             # silence Test::Pod::Coverage warning
39             =for Pod::Coverage set_boundscheck set_debugging
40              
41             =cut
42              
43              
44              
45             }
46              
47              
48              
49              
50              
51             =head1 FUNCTIONS
52              
53              
54              
55             =cut
56              
57              
58              
59              
60              
61              
62             =head2 _flatten_into
63              
64             =for sig
65              
66             Signature: (in(m); indx b(m); indx [o] idx(m); double step; double min; PDL_Indx n)
67              
68             =for ref
69              
70             Bin a series of values and flatten into an existing list of indices.
71              
72             =for bad
73              
74             _flatten_into processes bad values.
75             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
76              
77              
78             =cut
79              
80              
81              
82              
83              
84              
85             *_flatten_into = \&PDL::_flatten_into;
86              
87              
88              
89              
90              
91             =head2 _flatten_into_grid
92              
93             =for sig
94              
95             Signature: (in(); indx b(); double edge(n); indx [o] idx())
96              
97             =for ref
98              
99             Bin a series of values on a specified grid and flatten into an existing list of indices.
100              
101             =for bad
102              
103             _flatten_into_grid processes bad values.
104             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
105              
106              
107             =cut
108              
109              
110              
111              
112              
113              
114             *_flatten_into_grid = \&PDL::_flatten_into_grid;
115              
116              
117              
118              
119              
120             =head2 _setnulltobad
121              
122             =for sig
123              
124             Signature: (in(); indx count(); [o] out())
125              
126             =for ref
127              
128             Set empty bins to the bad value.
129              
130             =for bad
131              
132             _setnulltobad processes bad values.
133             The state of the bad-value flag of the output piddles is unknown.
134              
135              
136             =cut
137              
138              
139              
140              
141              
142              
143             *_setnulltobad = \&PDL::_setnulltobad;
144              
145              
146              
147              
148              
149             =head2 _icount_loop
150              
151             =for sig
152              
153             Signature: (in(n); indx idx(n); indx [o] out(m); PDL_Indx msize => m)
154              
155             Count the number of elements in each bin.
156              
157             This function returns a piddle of type I if you have a 64-bit-capable
158             PDL, otherwise it returns a piddle of type I.
159              
160             =for bad
161              
162             _icount_loop processes bad values.
163             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
164              
165              
166             =cut
167              
168              
169              
170              
171              
172              
173             *_icount_loop = \&PDL::_icount_loop;
174              
175              
176              
177              
178              
179             =head2 _imax_loop
180              
181             =for sig
182              
183             Signature: (in(n); indx idx(n); [o] out(m); PDL_Indx msize => m)
184              
185             =for ref
186              
187             Find the maximum in each bin.
188              
189             =for bad
190              
191             _imax_loop processes bad values.
192             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
193              
194              
195             =cut
196              
197              
198              
199              
200              
201              
202             *_imax_loop = \&PDL::_imax_loop;
203              
204              
205              
206              
207              
208             =head2 _imin_loop
209              
210             =for sig
211              
212             Signature: (in(n); indx idx(n); [o] out(m); PDL_Indx msize => m)
213              
214             =for ref
215              
216             Find the minimum in each bin.
217              
218             =for bad
219              
220             _imin_loop processes bad values.
221             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
222              
223              
224             =cut
225              
226              
227              
228              
229              
230              
231             *_imin_loop = \&PDL::_imin_loop;
232              
233              
234              
235              
236              
237             =head2 _isum_loop
238              
239             =for sig
240              
241             Signature: (in(n); indx idx(n); int+ [o] out(m); indx [t] count(m); PDL_Indx msize => m)
242              
243             Sum the elements in each bin.
244              
245             This function returns a piddle of type I or higher, to reduce the risk of
246             overflow when collecting sums.
247              
248             =for bad
249              
250             _isum_loop processes bad values.
251             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
252              
253              
254             =cut
255              
256              
257              
258              
259              
260              
261             *_isum_loop = \&PDL::_isum_loop;
262              
263              
264              
265              
266              
267             =head2 _iavg_loop
268              
269             =for sig
270              
271             Signature: (in(n); indx idx(n); double [o] out(m); indx [t] count(m); PDL_Indx msize => m)
272              
273             Compute the average of the elements in each bin.
274              
275             Credit for the algorithm goes to
276             L on commandlinefu.com|http://www.commandlinefu.com/commands/view/3437/compute-running-average-for-a-column-of-numbers>:
277              
278             awk '{ avg += ($1 - avg) / NR } END { print avg }'
279              
280             This is a wonderful solution solving many of the problems with more naive
281             implementations:
282              
283             =over 4
284              
285             =item 1.
286              
287             It's numerically well-behaved: out() is always of the order of magnitude of the
288             values themselves, unlike the sum of the values, which grows very large as the
289             number of elements grows large.
290              
291             =item 2.
292              
293             The subtraction in() - out() guarantees that the computation will be done in
294             the correct type (i.e., I instead of the type of the input).
295              
296             =item 3.
297              
298             Requires only one temporary.
299              
300             =item 4.
301              
302             Requires only one pass over the data.
303              
304             =back
305              
306             I used to give the output array type I, but that creates more problems
307             than it solves. So now, averages are always computed in type I. Besides
308             being the default type in PDL and the 'natural' floating-point type in C, it
309             also makes the implementation easier.
310              
311             =for bad
312              
313             _iavg_loop processes bad values.
314             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
315              
316              
317             =cut
318              
319              
320              
321              
322              
323              
324             *_iavg_loop = \&PDL::_iavg_loop;
325              
326              
327              
328              
329              
330             =head2 _istddev_loop
331              
332             =for sig
333              
334             Signature: (in(n); indx idx(n); double [o] out(m); indx [t] count(m); double [t] avg(m); PDL_Indx msize => m)
335              
336             Compute the standard deviation of the elements in each bin.
337              
338             Note that we compute the sample standard deviation, I an estimate of the
339             population standard deviation (which differs by a factor).
340              
341             Credit for the algorithm goes to
342             L on commandlinefu.com|http://www.commandlinefu.com/commands/view/3442/display-the-standard-deviation-of-a-column-of-numbers-with-awk>;
343              
344             awk '{ delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg) } END { print sqrt(mean2 / NR) }'
345              
346             This is a wonderful solution solving many of the problems with more naive
347             implementations:
348              
349             =over 4
350              
351             =item 1.
352              
353             It's numerically well-behaved.
354              
355             =item 2.
356              
357             The subtractions guarantee that the computations will be done in the correct
358             type (i.e., I instead of the type of the input).
359              
360             =item 3.
361              
362             Requires only two temporaries (!).
363              
364             =item 4.
365              
366             Requires only one pass over the data.
367              
368             =back
369              
370             I used to give the output array type I, but that creates more problems
371             than it solves. So now, standard deviations are always computed in type
372             I. Besides being the default type in PDL and the 'natural'
373             floating-point type in C, it also makes the implementation easier.
374              
375             =for bad
376              
377             _istddev_loop processes bad values.
378             It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
379              
380              
381             =cut
382              
383              
384              
385              
386              
387              
388             *_istddev_loop = \&PDL::_istddev_loop;
389              
390              
391              
392              
393              
394             =head2 _istddev_post
395              
396             =for sig
397              
398             Signature: (in(); indx count(); [o] out())
399              
400             =for ref
401              
402             Finalization for _istddev_loop().
403              
404             =for bad
405              
406             _istddev_post processes bad values.
407             The state of the bad-value flag of the output piddles is unknown.
408              
409              
410             =cut
411              
412              
413              
414              
415              
416              
417             *_istddev_post = \&PDL::_istddev_post;
418              
419              
420              
421              
422             =head1 AUTHOR
423              
424             Edward Baudrez
425              
426             =head1 COPYRIGHT AND LICENSE
427              
428             This software is copyright (c) 2014 by Edward Baudrez.
429              
430             This is free software; you can redistribute it and/or modify it under
431             the same terms as the Perl 5 programming language system itself.
432              
433             =cut
434              
435              
436              
437             ;
438              
439              
440              
441             # Exit with OK status
442              
443             1;
444              
445