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.019'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
2960
|
use strict; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
114
|
|
6
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
102
|
|
7
|
3
|
|
|
3
|
|
46
|
use PDL::Lite; # do not import any functions into this namespace |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
21
|
|
8
|
3
|
|
|
3
|
|
393
|
use Params::Validate qw( validate CODEREF OBJECT SCALAR UNDEF ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
1034
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
65
|
|
|
65
|
1
|
15787
|
my $class = shift; |
14
|
65
|
|
|
|
|
1340
|
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
|
|
|
|
|
1590
|
return bless $self, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub process |
24
|
|
|
|
|
|
|
{ |
25
|
264
|
|
|
264
|
1
|
521
|
my $self = shift; |
26
|
264
|
|
|
|
|
347
|
my $iter = shift; |
27
|
264
|
100
|
|
|
|
584
|
if( ! defined $self->{out} ) { |
28
|
65
|
100
|
|
|
|
218
|
my $type = defined $self->{type} ? $self->{type} : $iter->data->type; |
29
|
65
|
|
|
|
|
1512
|
$self->{out} = PDL->zeroes( $type, $self->{N} )->setbadif( 1 ); |
30
|
|
|
|
|
|
|
} |
31
|
264
|
|
|
|
|
5381
|
my $value = $self->{coderef}->( $iter ); |
32
|
261
|
100
|
|
|
|
22276
|
if( defined $value ) { $self->{out}->set( $iter->bin, $value ) } |
|
209
|
|
|
|
|
556
|
|
33
|
261
|
|
|
|
|
5087
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub result |
38
|
|
|
|
|
|
|
{ |
39
|
56
|
|
|
56
|
1
|
455
|
my $self = shift; |
40
|
56
|
|
|
|
|
175
|
return $self->{out}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |