line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDL::NDBin::Action::StdDev; |
2
|
|
|
|
|
|
|
# ABSTRACT: Action for PDL::NDBin that computes standard deviation |
3
|
|
|
|
|
|
|
$PDL::NDBin::Action::StdDev::VERSION = '0.019'; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
2129
|
use strict; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
58
|
|
6
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
69
|
|
7
|
2
|
|
|
2
|
|
12
|
use PDL::Lite; # do not import any functions into this namespace |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
8
|
2
|
|
|
2
|
|
231
|
use PDL::NDBin::Actions_PP; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
9
|
2
|
|
|
2
|
|
276
|
use Params::Validate qw( validate OBJECT SCALAR ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
740
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
45
|
|
|
45
|
1
|
6132
|
my $class = shift; |
15
|
45
|
|
|
|
|
283
|
my $self = validate( @_, { |
16
|
|
|
|
|
|
|
N => { type => SCALAR, regex => qr/^\d+$/ }, |
17
|
|
|
|
|
|
|
type => { type => OBJECT, isa => 'PDL::Type', default => PDL::double } |
18
|
|
|
|
|
|
|
} ); |
19
|
45
|
|
|
|
|
1636
|
return bless $self, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub process |
24
|
|
|
|
|
|
|
{ |
25
|
57
|
|
|
57
|
1
|
138
|
my $self = shift; |
26
|
57
|
|
|
|
|
88
|
my $iter = shift; |
27
|
57
|
100
|
|
|
|
255
|
$self->{out} = PDL->zeroes( $self->{type}, $self->{N} ) unless defined $self->{out}; |
28
|
57
|
50
|
|
|
|
2953
|
$self->{count} = PDL->zeroes( defined(&PDL::indx) ? PDL::indx() : PDL::long, $self->{N} ) unless defined $self->{count}; |
|
|
100
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# as the internal computations happen in double, the type of 'avg' sticks to double |
30
|
57
|
100
|
|
|
|
2481
|
$self->{avg} = PDL->zeroes( PDL::double, $self->{N} ) unless defined $self->{avg}; |
31
|
57
|
|
|
|
|
2371
|
PDL::NDBin::Actions_PP::_istddev_loop( $iter->data, $iter->idx, $self->{out}, $self->{count}, $self->{avg}, $self->{N} ); |
32
|
|
|
|
|
|
|
# as the plugin processes all bins at once, every variable |
33
|
|
|
|
|
|
|
# needs to be visited only once |
34
|
57
|
|
|
|
|
241
|
$iter->var_active( 0 ); |
35
|
57
|
|
|
|
|
197
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub result |
40
|
|
|
|
|
|
|
{ |
41
|
45
|
|
|
45
|
1
|
463
|
my $self = shift; |
42
|
45
|
|
|
|
|
136
|
$self->{out}->inplace->_istddev_post( $self->{count} ); |
43
|
45
|
|
|
|
|
1476
|
return $self->{out}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |