line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDL::NDBin::Action::Avg; |
2
|
|
|
|
|
|
|
# ABSTRACT: Action for PDL::NDBin that computes average |
3
|
|
|
|
|
|
|
$PDL::NDBin::Action::Avg::VERSION = '0.020'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
3007
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
93
|
|
6
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
87
|
|
7
|
3
|
|
|
3
|
|
16
|
use PDL::Lite; # do not import any functions into this namespace |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
24
|
|
8
|
3
|
|
|
3
|
|
362
|
use PDL::NDBin::Actions_PP; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
21
|
|
9
|
3
|
|
|
3
|
|
527
|
use Params::Validate qw( validate OBJECT SCALAR ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1034
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
51
|
|
|
51
|
1
|
77742
|
my $class = shift; |
15
|
51
|
|
|
|
|
337
|
my $self = validate( @_, { |
16
|
|
|
|
|
|
|
N => { type => SCALAR, regex => qr/^\d+$/ }, |
17
|
|
|
|
|
|
|
type => { type => OBJECT, isa => 'PDL::Type', default => PDL::double } |
18
|
|
|
|
|
|
|
} ); |
19
|
51
|
|
|
|
|
1880
|
return bless $self, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub process |
24
|
|
|
|
|
|
|
{ |
25
|
63
|
|
|
63
|
1
|
140
|
my $self = shift; |
26
|
63
|
|
|
|
|
88
|
my $iter = shift; |
27
|
63
|
100
|
|
|
|
280
|
$self->{out} = PDL->zeroes( $self->{type}, $self->{N} ) unless defined $self->{out}; |
28
|
63
|
50
|
|
|
|
3822
|
$self->{count} = PDL->zeroes( defined(&PDL::indx) ? PDL::indx() : PDL::long, $self->{N} ) unless defined $self->{count}; |
|
|
100
|
|
|
|
|
|
29
|
63
|
|
|
|
|
2956
|
PDL::NDBin::Actions_PP::_iavg_loop( $iter->data, $iter->idx, $self->{out}, $self->{count}, $self->{N} ); |
30
|
|
|
|
|
|
|
# as the plugin processes all bins at once, every variable |
31
|
|
|
|
|
|
|
# needs to be visited only once |
32
|
63
|
|
|
|
|
257
|
$iter->var_active( 0 ); |
33
|
63
|
|
|
|
|
212
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub result |
38
|
|
|
|
|
|
|
{ |
39
|
51
|
|
|
51
|
1
|
525
|
my $self = shift; |
40
|
51
|
|
|
|
|
149
|
$self->{out}->inplace->_setnulltobad( $self->{count} ); |
41
|
51
|
|
|
|
|
2046
|
return $self->{out}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |