line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDL::NDBin::Action::CodeRef; |
2
|
|
|
|
|
|
|
# ABSTRACT: Action for PDL::NDBin that calls user sub |
3
|
|
|
|
|
|
|
$PDL::NDBin::Action::CodeRef::VERSION = '0.020'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
2978
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
121
|
|
6
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
91
|
|
7
|
3
|
|
|
3
|
|
34
|
use PDL::Lite; # do not import any functions into this namespace |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
24
|
|
8
|
3
|
|
|
3
|
|
401
|
use Params::Validate qw( validate CODEREF OBJECT SCALAR UNDEF ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
987
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
65
|
|
|
65
|
1
|
15587
|
my $class = shift; |
14
|
65
|
|
|
|
|
1357
|
my $self = validate( @_, { |
15
|
|
|
|
|
|
|
N => { type => SCALAR, regex => qr/^\d+$/ }, |
16
|
|
|
|
|
|
|
coderef => { type => CODEREF }, |
17
|
|
|
|
|
|
|
type => { type => OBJECT | UNDEF, isa => 'PDL::Type', optional => 1 } |
18
|
|
|
|
|
|
|
} ); |
19
|
65
|
|
|
|
|
1588
|
return bless $self, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub process |
24
|
|
|
|
|
|
|
{ |
25
|
264
|
|
|
264
|
1
|
467
|
my $self = shift; |
26
|
264
|
|
|
|
|
348
|
my $iter = shift; |
27
|
264
|
100
|
|
|
|
599
|
if( ! defined $self->{out} ) { |
28
|
65
|
100
|
|
|
|
198
|
my $type = defined $self->{type} ? $self->{type} : $iter->data->type; |
29
|
65
|
|
|
|
|
1545
|
$self->{out} = PDL->zeroes( $type, $self->{N} )->setbadif( 1 ); |
30
|
|
|
|
|
|
|
} |
31
|
264
|
|
|
|
|
5338
|
my $value = $self->{coderef}->( $iter ); |
32
|
261
|
100
|
|
|
|
22464
|
if( defined $value ) { $self->{out}->set( $iter->bin, $value ) } |
|
209
|
|
|
|
|
511
|
|
33
|
261
|
|
|
|
|
4970
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub result |
38
|
|
|
|
|
|
|
{ |
39
|
56
|
|
|
56
|
1
|
449
|
my $self = shift; |
40
|
56
|
|
|
|
|
168
|
return $self->{out}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |